# !/usr/bin/python3
# -*- coding: utf-8 -*-
# ------------------------------------------
# @Time    : Date - 2021/9/4   Time - 10:56
# @Author  : Spence Guo Tang
# @FileName: T3.py
# ------------------------------------------

import sys


class TreeNode:
    def __init__(self, val=None, children=None):
        self.value = val
        self.children = children


def func(edges, k):
    result = 0
    for edge in edges:
        if edge[-1] <= k:
            result += 1
    return result


if __name__ == '__main__':
    line_1 = list(map(int, sys.stdin.readline().strip().split(" ")))
    line_2 = list(map(int, sys.stdin.readline().strip().split(" ")))

    # 结点数为 N, 到达对方的时间不超过 K
    N, K = line_1[0], line_1[1]
    edges = []

    for i in range(0, 3*(N-1), 3):
        edges.append(line_2[i:i+3])
    print(func(edges, K))
